/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package aaa.schedule.parameters;

import aaa.main.R;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;

/**
 *
 * @author Seb
 */
public class SchedulePeriod extends  ParameterType {

	public static final String FIELD_ID = "period" ;

	private String period;
	private LayoutInflater inflater;

	private EditText daySchedule;

	public SchedulePeriod (LayoutInflater inflater, String period) {
		super(FIELD_ID) ;
		this.inflater = inflater ;
		this.period = period;
	}

	public Object getValue(View view) {
		this.daySchedule = (EditText) view.findViewById(R.id.daySchedule);
		Integer value = 0 ;
		try {
			value = Integer.parseInt(this.daySchedule.getText().toString());
		} catch (NumberFormatException e) {} ;
		return value ;
	}

	public View getView(View convertView, ViewGroup parent) {
		convertView = inflater.inflate(R.layout.type_schedule_period, null);

		daySchedule = (EditText) convertView.findViewById(R.id.daySchedule);
		daySchedule.setText(this.period);

		return convertView;
	} 

}
